package com.rocching.easychat.model;

import android.net.Uri;
import android.util.Log;

import io.rong.imlib.model.UserInfo;

public class FriendModel {
    private long id;
    private Integer type;
    private String firstChar;
    private String account;
    private String name;
    private String phone;
    private String photo;
    private String description;
    private String remark;
    private String friendName;
    private String greetMsg;

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public Integer getType() {
        return type;
    }

    public void setType(Integer type) {
        this.type = type;
    }

    public String getFirstChar() {
        return firstChar;
    }

    public void setFirstChar(String firstChar) {
        this.firstChar = firstChar;
    }

    public String getAccount() {
        return account;
    }

    public void setAccount(String account) {
        this.account = account;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPhone() {
        return phone;
    }

    public String getPhoto() {
        return photo;
    }

    public void setPhoto(String photo) {
        this.photo = photo;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public String getFriendName() {
        return friendName;
    }

    public void setFriendName(String friendName) {
        this.friendName = friendName;
    }

    public String getGreetMsg() {
        return greetMsg;
    }

    public void setGreetMsg(String greetMsg) {
        this.greetMsg = greetMsg;
    }

    public boolean hasChanged(UserInfo userInfo) {
        if (compareField(userInfo.getName(), this.name)) {
            return true;
        }
        if (compareField(userInfo.getAlias(), this.remark)) {
            return true;
        }
        Uri uri = userInfo.getPortraitUri();
        if (uri != null) {
            if (compareField(uri.getPath(), this.photo)) {
                return true;
            }
        }
        return false;
    }

    private boolean compareField(String s1, String s2) {
        if (s1 == null) {
            s1 = "";
        }
        if (s2 == null) {
            s2 = "";
        }
        Log.i("ROC", "the s1 is:[" + s1 + "] ,the s2 is:[" + s2 + "]");
        return !s1.equals(s2);
    }
}
